<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Class - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Module.html">Module</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-allocate">#allocate</a>
    <li ><a href="#method-i-attached_object">#attached_object</a>
    <li ><a href="#method-i-inherited">#inherited</a>
    <li ><a href="#method-i-new">#new</a>
    <li ><a href="#method-i-subclasses">#subclasses</a>
    <li ><a href="#method-i-superclass">#superclass</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Class">
    <h1 id="class-Class" class="class">
      class Class
    </h1>

    <section class="description">
    
<p>Classes in Ruby are first-class objects—each is an instance of class <a href="Class.html"><code>Class</code></a>.</p>

<p>Typically, you create a new class by using:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Name</span>
 <span class="ruby-comment"># some code describing the class behavior</span>
<span class="ruby-keyword">end</span>
</pre>

<p>When a new class is created, an object of type <a href="Class.html"><code>Class</code></a> is initialized and assigned to a global constant (Name in this case).</p>

<p>When <code>Name.new</code> is called to create a new object, the <a href="Class.html#method-i-new"><code>new</code></a> method in <a href="Class.html"><code>Class</code></a> is run by default. This can be demonstrated by overriding <a href="Class.html#method-i-new"><code>new</code></a> in Class:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Class</span>
  <span class="ruby-keyword">alias</span> <span class="ruby-identifier">old_new</span> <span class="ruby-identifier">new</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
    <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;Creating a new &quot;</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">name</span>, <span class="ruby-string">&quot;\n&quot;</span>
    <span class="ruby-identifier">old_new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">Name</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">n</span> = <span class="ruby-constant">Name</span>.<span class="ruby-identifier">new</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Creating</span> <span class="ruby-identifier">a</span> <span class="ruby-identifier">new</span> <span class="ruby-constant">Name</span>
</pre>

<p>Classes, modules, and objects are interrelated. In the diagram that follows, the vertical arrows represent inheritance, and the parentheses metaclasses. All metaclasses are instances of the class ‘Class’.</p>

<pre>                         +---------+             +-...
                         |         |             |
         BasicObject-----|--&gt;(BasicObject)-------|-...
             ^           |         ^             |
             |           |         |             |
          Object---------|-----&gt;(Object)---------|-...
             ^           |         ^             |
             |           |         |             |
             +-------+   |         +--------+    |
             |       |   |         |        |    |
             |    Module-|---------|---&gt;(Module)-|-...
             |       ^   |         |        ^    |
             |       |   |         |        |    |
             |     Class-|---------|----&gt;(Class)-|-...
             |       ^   |         |        ^    |
             |       +---+         |        +----+
             |                     |
obj---&gt;OtherClass----------&gt;(OtherClass)-----------...</pre>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(super_class=Object)               &rarr; a_class
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(super_class=Object) { |mod| ... } &rarr; a_class
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new anonymous (unnamed) class with the given superclass (or <a href="Object.html"><code>Object</code></a> if no parameter is given). You can give a class a name by assigning the class object to a constant.</p>

<p>If a block is given, it is passed the class object, and the block is evaluated in the context of this class like <a href="Module.html#method-i-class_eval"><code>class_eval</code></a>.</p>

<pre class="ruby"><span class="ruby-identifier">fred</span> = <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">meth1</span>
    <span class="ruby-string">&quot;hello&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">meth2</span>
    <span class="ruby-string">&quot;bye&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">a</span> = <span class="ruby-identifier">fred</span>.<span class="ruby-identifier">new</span>     <span class="ruby-comment">#=&gt; #&lt;#&lt;Class:0x100381890&gt;:0x100376b98&gt;</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">meth1</span>          <span class="ruby-comment">#=&gt; &quot;hello&quot;</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">meth2</span>          <span class="ruby-comment">#=&gt; &quot;bye&quot;</span>
</pre>

<p>Assign the class to a constant (name starting uppercase) if you want to treat it like a regular class.</p>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
rb_class_initialize(int argc, VALUE *argv, VALUE klass)
{
    VALUE super;

    if (RCLASS_SUPER(klass) != 0 || klass == rb_cBasicObject) {
        rb_raise(rb_eTypeError, &quot;already initialized class&quot;);
    }
    if (rb_check_arity(argc, 0, 1) == 0) {
        super = rb_cObject;
    }
    else {
        super = argv[0];
        rb_check_inheritable(super);
        if (super != rb_cBasicObject &amp;&amp; !RCLASS_SUPER(super)) {
            rb_raise(rb_eTypeError, &quot;can&#39;t inherit uninitialized class&quot;);
        }
    }
    RCLASS_SET_SUPER(klass, super);
    rb_make_metaclass(klass, RBASIC(super)-&gt;klass);
    rb_class_inherited(super, klass);
    rb_mod_initialize_exec(klass);

    return klass;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-allocate" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          allocate()   &rarr;   obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Allocates space for a new object of <em>class</em>’s class and does not call initialize on the new instance. The returned object must be an instance of <em>class</em>.</p>

<pre class="ruby"><span class="ruby-identifier">klass</span> = <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
    <span class="ruby-ivar">@initialized</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialized?</span>
    <span class="ruby-ivar">@initialized</span> <span class="ruby-operator">||</span> <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">klass</span>.<span class="ruby-identifier">allocate</span>.<span class="ruby-identifier">initialized?</span> <span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="allocate-source">
            <pre>static VALUE
rb_class_alloc_m(VALUE klass)
{
    rb_alloc_func_t allocator = class_get_alloc_func(klass);
    if (!rb_obj_respond_to(klass, rb_intern(&quot;allocate&quot;), 1)) {
        rb_raise(rb_eTypeError, &quot;calling %&quot;PRIsVALUE&quot;.allocate is prohibited&quot;,
                 klass);
    }
    return class_call_alloc_func(allocator, klass);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-attached_object" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          attached_object &rarr; object
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the object for which the receiver is the singleton class.</p>

<p>Raises an <a href="TypeError.html"><code>TypeError</code></a> if the class is not a singleton class.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Foo</span>; <span class="ruby-keyword">end</span>

<span class="ruby-constant">Foo</span>.<span class="ruby-identifier">singleton_class</span>.<span class="ruby-identifier">attached_object</span>        <span class="ruby-comment">#=&gt; Foo</span>
<span class="ruby-constant">Foo</span>.<span class="ruby-identifier">attached_object</span>                        <span class="ruby-comment">#=&gt; TypeError: `Foo&#39; is not a singleton class</span>
<span class="ruby-constant">Foo</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">singleton_class</span>.<span class="ruby-identifier">attached_object</span>    <span class="ruby-comment">#=&gt; #&lt;Foo:0x000000010491a370&gt;</span>
<span class="ruby-constant">TrueClass</span>.<span class="ruby-identifier">attached_object</span>                  <span class="ruby-comment">#=&gt; TypeError: `TrueClass&#39; is not a singleton class</span>
<span class="ruby-constant">NilClass</span>.<span class="ruby-identifier">attached_object</span>                   <span class="ruby-comment">#=&gt; TypeError: `NilClass&#39; is not a singleton class</span>
</pre>

                              <div class="method-source-code" id="attached_object-source">
            <pre>VALUE
rb_class_attached_object(VALUE klass)
{
    if (!FL_TEST(klass, FL_SINGLETON)) {
        rb_raise(rb_eTypeError, &quot;`%&quot;PRIsVALUE&quot;&#39; is not a singleton class&quot;, klass);
    }

    return RCLASS_ATTACHED_OBJECT(klass);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(args, ...)    &rarr;  obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calls <a href="Class.html#method-i-allocate"><code>allocate</code></a> to create a new object of <em>class</em>’s class, then invokes that object’s initialize method, passing it <em>args</em>.  This is the method that ends up getting called whenever an object is constructed using <code>.new</code>.</p>

                              <div class="method-source-code" id="new-source">
            <pre>VALUE
rb_class_new_instance_pass_kw(int argc, const VALUE *argv, VALUE klass)
{
    VALUE obj;

    obj = rb_class_alloc(klass);
    rb_obj_call_init_kw(obj, argc, argv, RB_PASS_CALLED_KEYWORDS);

    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-subclasses" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          subclasses &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of classes where the receiver is the direct superclass of the class, excluding singleton classes. The order of the returned array is not defined.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">A</span>; <span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">A</span>; <span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">C</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">B</span>; <span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">D</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">A</span>; <span class="ruby-keyword">end</span>

<span class="ruby-constant">A</span>.<span class="ruby-identifier">subclasses</span>        <span class="ruby-comment">#=&gt; [D, B]</span>
<span class="ruby-constant">B</span>.<span class="ruby-identifier">subclasses</span>        <span class="ruby-comment">#=&gt; [C]</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">subclasses</span>        <span class="ruby-comment">#=&gt; []</span>
</pre>

<p>Anonymous subclasses (not associated with a constant) are returned, too:</p>

<pre class="ruby"><span class="ruby-identifier">c</span> = <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">A</span>)
<span class="ruby-constant">A</span>.<span class="ruby-identifier">subclasses</span>        <span class="ruby-comment"># =&gt; [#&lt;Class:0x00007f003c77bd78&gt;, D, B]</span>
</pre>

<p>Note that the parent does not hold references to subclasses and doesn’t prevent them from being garbage collected. This means that the subclass might disappear when all references to it are dropped:</p>

<pre class="ruby"><span class="ruby-comment"># drop the reference to subclass, it can be garbage-collected now</span>
<span class="ruby-identifier">c</span> = <span class="ruby-keyword">nil</span>

<span class="ruby-constant">A</span>.<span class="ruby-identifier">subclasses</span>
<span class="ruby-comment"># It can be</span>
<span class="ruby-comment">#  =&gt; [#&lt;Class:0x00007f003c77bd78&gt;, D, B]</span>
<span class="ruby-comment"># ...or just</span>
<span class="ruby-comment">#  =&gt; [D, B]</span>
<span class="ruby-comment"># ...depending on whether garbage collector was run</span>
</pre>

                              <div class="method-source-code" id="subclasses-source">
            <pre>VALUE
rb_class_subclasses(VALUE klass)
{
    return class_descendants(klass, true);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-superclass" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          superclass &rarr; a_super_class or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the superclass of <em>class</em>, or <code>nil</code>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">superclass</span>          <span class="ruby-comment">#=&gt; IO</span>
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">superclass</span>            <span class="ruby-comment">#=&gt; Object</span>
<span class="ruby-constant">Object</span>.<span class="ruby-identifier">superclass</span>        <span class="ruby-comment">#=&gt; BasicObject</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">Foo</span>; <span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">Bar</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Foo</span>; <span class="ruby-keyword">end</span>
<span class="ruby-constant">Bar</span>.<span class="ruby-identifier">superclass</span>           <span class="ruby-comment">#=&gt; Foo</span>
</pre>

<p>Returns nil when the given class does not have a parent class:</p>

<pre class="ruby"><span class="ruby-constant">BasicObject</span>.<span class="ruby-identifier">superclass</span>   <span class="ruby-comment">#=&gt; nil</span>
</pre>

                              <div class="method-source-code" id="superclass-source">
            <pre>VALUE
rb_class_superclass(VALUE klass)
{
    RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));

    VALUE super = RCLASS_SUPER(klass);

    if (!super) {
        if (klass == rb_cBasicObject) return Qnil;
        rb_raise(rb_eTypeError, &quot;uninitialized class&quot;);
    }

    if (!RCLASS_SUPERCLASS_DEPTH(klass)) {
        return Qnil;
    }
    else {
        super = RCLASS_SUPERCLASSES(klass)[RCLASS_SUPERCLASS_DEPTH(klass) - 1];
        RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
        return super;
    }
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-inherited" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          inherited(subclass)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Callback invoked whenever a subclass of the current class is created.</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Foo</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">inherited</span>(<span class="ruby-identifier">subclass</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;New subclass: #{subclass}&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">Bar</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Foo</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">Baz</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Bar</span>
<span class="ruby-keyword">end</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">New</span> <span class="ruby-value">subclass:</span> <span class="ruby-constant">Bar</span>
<span class="ruby-constant">New</span> <span class="ruby-value">subclass:</span> <span class="ruby-constant">Baz</span>
</pre>

                              <div class="method-source-code" id="inherited-source">
            <pre>#define rb_obj_class_inherited rb_obj_dummy1</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

